package com.ym.common.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.persistence.Table;

/**
 * 业务公用方法
 */
public class CommonUtil {

	private static final Logger LOGGER = LoggerFactory.getLogger(CommonUtil.class);


	/**
	 * 获取表名
	 *
	 * @param cls
	 * @return
	 */
	public static String getTableName(Class<?> cls) {
		Table tableName = cls.getAnnotation(Table.class);
		if (tableName == null || "".equals(tableName.name())) {
			return StringUtil.toUnderScoreCase(cls.getSimpleName());
		} else {
			return tableName.name();
		}
	}
}
